package org.example.maven.mapper;

import org.apache.ibatis.annotations.*;
import org.example.maven.pojo.position.AddPosition;
import org.example.maven.pojo.position.PositionListTable;
import org.example.maven.pojo.position.SearchPosition;
import org.example.maven.pojo.position.utils.PositionSelect;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

@Mapper
public interface PositionMapper {
    //获取岗位的lsittable信息
    @Select("select *from position_department")
    List<PositionListTable> getAllPositionList();

    //添加岗位
    @Insert("insert into `position`(position_name,dept_id,responsibility,max_headcount,status,create_time) values (#{positionName},#{deptId},#{responsibility},#{maxHeadcount},#{status},#{time})")
    void addPosition(AddPosition addPosition);

    //获取分页total的值
    Integer getPositionCount(SearchPosition searchPosition);

    //获取特定的岗位信息
    List<PositionListTable> getSpeciePosition(SearchPosition searchPosition);

    //逻辑删除岗位
    void deletePosition(@Param("ids") String[] id);

    //获取编辑的岗位信息
    @Select("select *from position_department where id=#{id}")
    AddPosition getEditPositionDetail(Integer id);

    //更新岗位信息
    void updatePosition(AddPosition addPosition);

    //判断添加的岗位在逻辑删除里是否存在
    @Results({
            @Result(property = "id", column = "position_id"),
    })
    @Select("select position_id from `position` where position_name=#{name} and is_deleted=1")
    AddPosition getPositionIsDeletedLive(String name);

    //判断添加的岗位是否存在
    @Results({
            @Result(property = "id", column = "position_id"),
    })
    @Select("select position_id from `position` where position_name=#{name} and is_deleted=0")
    AddPosition getPositionLive(String name);

    //更新逻辑删除的岗位
    void updatePositionIsDeleted(AddPosition addPosition);

    //根据部门id获取对应的岗位select选项
    List<PositionSelect> getPositionByDepartmentId(Integer id);

}
